using System;
using System.Collections.Generic;
using System.Text;
using System.Diagnostics;

namespace Aces4All.Logger
{
    /// <summary>
    /// Class for making entries to Windows Event log
    /// </summary>
    public class WinEventLog : ILog
    {
        #region private fields

        private EventLog m_EventLog;

        #endregion

        #region public constructors

        /// <summary>
        /// Creates new instance of WinEventLog
        /// </summary>
        /// <param name="eventLogName">
        /// Windows event log entry will be made to
        /// </param>
        /// <param name="applicationSource">
        /// Name of application making log entry
        /// </param>
        public WinEventLog(string eventLogName, string applicationSource)
        {
            this.m_Log = eventLogName;
            this.m_Source = applicationSource;

            this.m_EventLog = new EventLog(this.m_Log);
            this.m_EventLog.Source = this.m_Source;
        }

        #endregion

        #region public properties

        private string m_Log;
        /// <summary>
        /// Windows Event Log name
        /// </summary>
        public string Log
        {
            get
            {
                return this.m_Log;
            }
        }

        private string m_Source;
        /// <summary>
        /// Source of application making log entries
        /// </summary>
        public string Source
        {
            get
            {
                return this.m_Source;
            }
        }

        #endregion

        #region public methods

        /// <summary>
        /// Write entry to specified Windows Event Log.
        /// </summary>
        public void WriteEntry(LogEntry entry)
        {
            this.m_EventLog.WriteEntry(entry.Message, entry.EntryType);
        }

        #endregion
    }
}
